<?php Yii::app()->clientScript->registerScriptFile(Yii::app()->params['static'].'assets/js/bootbox.min.js',2); ?>
<div class="col-xs-12">
		    <div class="widget-box">
					<div class="widget-header widget-header-small">
						<h5></h5>
					</div>

		<div class="widget-body">
		<div class="widget-main">
			
										<div class="tabbable">
											<ul class="nav nav-tabs padding-12 tab-color-blue background-blue" id="myTab4">
												<li class="active">
													<a data-toggle="tab" href="#form1">第一学期</a>
												</li>
                                                <li class="">
													<a data-toggle="tab" href="#form2">第二学期</a>
												</li>
												
												<li class="">
													<a data-toggle="tab" href="#form3">第三学期</a>
												</li>
												<li class="">
													<a data-toggle="tab" href="#form4">第四学期</a>
												</li>
												<li class="">
													<a data-toggle="tab" href="#form5">第五学期</a>
												</li>
												<li class="">
													<a data-toggle="tab" href="#form6">第六学期</a>
												</li>
												<li class="">
													<a data-toggle="tab" href="#form7">第七学期</a>
												</li>
												<li class="">
													<a data-toggle="tab" href="#form8">第八学期</a>
												</li>
											</ul>

											<div class="tab-content">
												<div id="form1" class="tab-pane active">
													<?php echo $this->renderPartial('_1_check',array('scs'=>$scs[0])); ?>
												</div>
                                                <div id="form2" class="tab-pane">
												    <?php echo $this->renderPartial('_2_check',array('scs'=>$scs[1])); ?>
												</div>
												<div id="form3" class="tab-pane">
													 <?php echo $this->renderPartial('_3_check',array('scs'=>$scs[2])); ?>
												</div>
                                                 <div id="form4" class="tab-pane">
													 <?php echo $this->renderPartial('_4_check',array('scs'=>$scs[3])); ?>
												</div>
												<div id="form5" class="tab-pane">
													<?php echo $this->renderPartial('_5_check',array('scs'=>$scs[4])); ?>
												</div>
												<div id="form6" class="tab-pane">
													 <?php echo $this->renderPartial('_6_check',array('scs'=>$scs[5])); ?>
												</div>
												<div id="form7" class="tab-pane">
													<?php echo $this->renderPartial('_7_check',array('scs'=>$scs[6])); ?>
												</div>
												<div id="form8" class="tab-pane">
													 <?php echo $this->renderPartial('_8_check',array('scs'=>$scs[7])); ?>
												</div>
												
											</div>
										</div>
						
										
		
        </div>
										
	  </div>
	 </div>
  </div>

 <script type="text/javascript">

			jQuery(function($) {
				<?php
				   if(Yii::app()->user->hasFlash('teacherAdd')){
					   echo 'bootbox.alert("'.Yii::app()->user->getFlash('teacherAdd').'",function(){});';
					   
				   }
				?>
				
				$('table th input:checkbox').on('click' , function(){
					var that = this;
					$(this).closest('table').find('tr > td:first-child input:checkbox')
					.each(function(){
						this.checked = that.checked;
						$(this).closest('tr').toggleClass('selected');
					});
						
				});
			 //修改学分，增加综合奖学金的审核通知
			  $("[edit-sch]").on('click',function(){
				var tr = $("[stu-sch-id="+$(this).attr('edit-sch')+"]");
				
                bootbox.dialog({
                title: "修改综合奖学金信息",
                message: '<div class="row">  ' +
                    '<div class="col-md-12"> ' +
                    '<form class="form-horizontal" id = "edit-sch-detail" method="post" action="<?php echo Yii::app()->createUrl('stuscholarship/studetail'); ?>"> ' +
					
					'<div class="form-group">'+
					'<label class="col-md-4 control-label" for="name">模块:</label> ' +
                    '<label class="col-md-4" for="name">'+$(tr).children(".sch-module").html()+'</label> ' +
                    '</div>'+
					'<div class="form-group">'+
					'<label class="col-md-4 control-label" for="name">添加时间:</label> ' +
                    '<label class="col-md-4" for="name">'+$(tr).children(".sch-addtime").html()+'</label> ' +
                    '</div>'+
                    '<div class="form-group"> ' +
                    '<label class="col-md-4 control-label" for="name">学分:</label> ' +
                    '<div class="col-md-4"> ' +
                    '<input  id="changed-credit" type="text" placeholder="修改学分" class="form-control input-md" value="'+$(tr).children(".sch-credit").html()+'"> ' +
                    '<span class="help-block">可以在这里修改该条记录的学分</span> </div> ' +
                    '</div> ' +
                    '<div class="form-group"> ' +
                    '<label class="col-md-4 control-label" for="awesomeness">详情</label> ' +
                    '<div class="col-md-4"> ' +
					'<textarea id="changed-detail" class="form-control" col="20" rows="6">'+$(tr).children(".sch-detail").html()+'</textarea>'+
                    '</div> </div>' +
                    '</form> </div>  </div>',
                buttons: {
                    success: {
                        label: "保存",
                        className: "btn-success",
                        callback: function () {
							var id = $(tr).attr('stu-sch-id');
                            var credit = $('#changed-credit').val();
							var detail = $('#changed-detail').val();
						     $.post('<?php echo Yii::app()->createUrl('scholarship/updatescholaritem'); ?>',{'credit':credit,'detail':detail,'stuScholarItemId':id},function(data){
								data = $.parseJSON(data);
									if(data){
										bootbox.alert(data['msg'],function(){
											if(data['code'] == '200'){
											$('[stu-gsp-id = '+id+']').fadeToggle('900','linear',function(){
											   $(this).remove();
											});
										   
										}
									   
									   });
										
										
									}else{
										bootbox.alert('额额，好像服务器君出错了！！',function(){
											
										});
										
									}
								
								
							});
						   
                           
                        }
                    }
                }
            }
        );				
			return false;	
			});
			//在审核的过程中添加备注信息
			  $("[thumbs-down]").on('click',function(){
				  var id = $(this).attr('thumbs-down');
				  
				  bootbox.prompt({
					  title:"添加备注",
					  value: "同学，您的这条记录有误",
					   
					  callback: function(result) {                
						  if (result === null) {                                             
							                              
						  } else {
							$.post('<?php echo Yii::app()->createUrl('scholarship/addcomment'); ?>',{'stuScholarItemId':id,'comment':result},function(data){
								data = $.parseJSON(data);
								if(data){
									bootbox.alert(data['msg'],function(){
										if(data['code'] == '200'){
										$('[stu-sch-id = '+id+']').fadeToggle('800','linear',function(){
									       $(this).remove();
										});
									   
									}
							       
								   });
									
									
						        }else{
									bootbox.alert('额额，好像服务器君出错了！！',function(){
										
									});
									
								}
								
								
							});                       
						  }}
				  });
				   return false;
				  
			  });
			// 通过一个学生
			$('[thumbs-up]').on('click',function(){
				 var id = $(this).attr('thumbs-up');
				  $.post('<?php echo Yii::app()->createUrl('scholarship/passone'); ?>',{'stuScholarItemId':id},function(data){
                      if(data){
						  data = $.parseJSON(data);
						  bootbox.alert(data['msg'],function(){
						      if(data['code'] == '200'){
										$('[stu-sch-id = '+id+']').fadeToggle('800','linear',function(){
									       $(this).remove();
										});
									   
									}
						  });
						  
						  
					  }else{
						  bootbox.alert('抱歉，服务器君好像出错了',function(){});
					  }					  
					  
				  });
				  return false;
				
			});
			
			 $('[muti-up]').on('click',function(){
				 var form = $(this).attr('muti-up');
				  bootbox.confirm('确定要将这些条目通过审核吗？',function(result){
					 if(result){
						  var stus = $('#'+form).serialize();
					      $.post('<?php echo Yii::app()->createUrl('scholarship/passmuti'); ?>',{'stus':stus},function(data){
								console.log(data);
								data = $.parseJSON(data);
								if(data){
									bootbox.alert(data['msg'],function(){
										for(i in data['successArray']){
										$('[stu-sch-id = '+data['successArray'][i]+']').fadeToggle('500','linear',function(){
									       $(this).remove();
										});
									  }
							        });
									
									
						        }else{
									bootbox.alert('额额，好像服务器君出错了！！',function(){
										
									});
									
								}
								
								
							});    
						 
					 }
				  });
				  
				  return false;
				  
			  });
			  $('[muti-down]').on('click',function(){
				  var form = $(this).attr('muti-down');
				  bootbox.confirm('确定要将这些条目不通过审核吗？',function(result){
					  if(result){
						  
						  var stus = $('#'+form).serialize();
					      $.post('<?php echo Yii::app()->createUrl('scholarship/unpassmuti'); ?>',{'stus':stus},function(data){
								console.log(data);
								data = $.parseJSON(data);
								if(data){
									bootbox.alert(data['msg'],function(){
										for(i in data['successArray']){
										$('[stu-sch-id = '+data['successArray'][i]+']').fadeToggle('500','linear',function(){
									       $(this).remove();
										});
									  }
							        });
									
									
						        }else{
									bootbox.alert('额额，好像服务器君出错了！！',function(){
										
									});
									
								}
								
								
							});    
						  
					  }
				  });
				  
				  return false;
				  
			  });
				
			
			
			
			
			
			
			
			})
		
</script>